package com.owen.oauth2.resource.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;
import org.springframework.security.oauth2.config.annotation.web.configurers.ResourceServerSecurityConfigurer;
import org.springframework.security.oauth2.provider.token.RemoteTokenServices;

@Configuration
public class OAuth2Config extends ResourceServerConfigurerAdapter {
    private static final String URL = "http://localhost:9000/oauth/check_token";
    @Override
    public void configure(ResourceServerSecurityConfigurer resources) throws Exception {
        RemoteTokenServices tokenServices=new RemoteTokenServices();
        tokenServices.setClientId("test");
        tokenServices.setClientSecret("test");
        tokenServices.setCheckTokenEndpointUrl(URL);

        resources.tokenServices(tokenServices);
    }
}
